package com.minimalist.basic.controller.lindi;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationpayrecord.LindiSubsidyApplicationPayRecordQueryVO;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationpayrecord.LindiSubsidyApplicationPayRecordVO;
import com.minimalist.common.feign.client.lindi.LindiSubsidyApplicationPayRecordFeignClient;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * 林地指标交易平台_补贴支付记录控制器
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_补贴申请支付记录管理")
@RequestMapping("/basic/lindi/subsidyApplicationPayRecord")
public class LindiSubsidyApplicationPayRecordController{

    @Autowired
    private LindiSubsidyApplicationPayRecordFeignClient feignClient;

    @PostMapping("/addSubsidyApplicationPayRecord")
    @Operation(summary = "添加补贴申请支付记录")
    @SaCheckPermission("lindi:subsidyApplicationPayRecord:add")
    public R<?> addSubsidyApplicationPayRecord(
            @RequestBody @Validated(Add.class) LindiSubsidyApplicationPayRecordVO
                    subsidyApplicationPayRecordVO){
        subsidyApplicationPayRecordVO.setCreateId(StpUtil.getLoginIdAsLong());
        subsidyApplicationPayRecordVO.setUpdateId(StpUtil.getLoginIdAsLong());
        LocalDateTime now = LocalDateTime.now();
        subsidyApplicationPayRecordVO.setCreateTime(now);
        subsidyApplicationPayRecordVO.setUpdateTime(now);
        return feignClient.addSubsidyApplicationPayRecord(subsidyApplicationPayRecordVO);
    }

    @DeleteMapping("/deleteSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId")
    @Operation(summary = "删除补贴申请支付记录 -> 根据补贴申请支付记录ID删除")
    @SaCheckPermission("lindi:subsidyPayRecord:delete")
    public R<?> deleteSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId(
            @RequestParam("subsidyApplicationPayRecordId")
            @NotNull(message = "补贴申请支付记录ID不能为空")
            @Parameter(name = "subsidyApplicationPayRecordId", required = true, description = "补贴申请支付记录ID")
            Long subsidyApplicationPayRecordId){
        return feignClient.deleteSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId(
                subsidyApplicationPayRecordId);
    }

    @PutMapping("/updateSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId")
    @Operation(summary = "修改补贴申请支付记录")
    @SaCheckPermission("lindi:subsidyApplicationPayRecord:update")
    public R<?> updateSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId(
            @RequestBody @Validated(Update.class) LindiSubsidyApplicationPayRecordVO
                    subsidyApplicationPayRecordVO){
        subsidyApplicationPayRecordVO.setUpdateId(StpUtil.getLoginIdAsLong());
        LocalDateTime now = LocalDateTime.now();
        subsidyApplicationPayRecordVO.setUpdateTime(now);
        return feignClient.updateSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId(
                subsidyApplicationPayRecordVO);
    }

    @GetMapping("/getPageSubsidyApplicationPayRecordList")
    @Operation(summary = "查询补贴申请支付记录列表(分页)")
    @SaCheckPermission("lindi:subsidyApplicationPayRecord:get")
    public R<PageResp<LindiSubsidyApplicationPayRecordVO>> getPageSubsidyApplicationPayRecordList(
            LindiSubsidyApplicationPayRecordQueryVO queryVO){
        return feignClient.getPageSubsidyApplicationPayRecordList(queryVO);
    }

    @GetMapping("/getSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId/{subsidyApplicationPayRecordId}")
    @Operation(summary = "根据补贴申请支付记录ID查询补贴申请支付记录")
    @SaCheckPermission("lindi:subsidyApplicationPayRecord:get")
    public R<LindiSubsidyApplicationPayRecordVO>
    getSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId(
            @PathVariable(value = "subsidyApplicationPayRecordId")
            @NotNull(message = "补贴申请支付记录ID不能为空")
            @Parameter(name = "subsidyApplicationPayRecordId", description = "补贴申请支付记录ID", required = true)
            Long subsidyApplicationPayRecordId){
        return feignClient.getSubsidyApplicationPayRecordBySubsidyApplicationPayRecordId
                (subsidyApplicationPayRecordId);
    }

    @GetMapping("/getSubsidyApplicationPayRecordListBySubsidyApplicationId/{subsidyApplicationId}")
    @Operation(summary = "根据补贴申请ID查询支付记录列表")
    @SaCheckPermission("lindi:subsidyApplicationPayRecord:get")
    public R<PageResp<LindiSubsidyApplicationPayRecordVO>> getSubsidyApplicationPayRecordListBySubsidyApplicationId(
            @PathVariable(value = "subsidyApplicationId")
            @NotNull(message = "补贴申请ID不能为空")
            @Parameter(name = "subsidyApplicationId", description = "补贴申请ID", required = true)
            Long subsidyApplicationId){
        return feignClient.getSubsidyApplicationPayRecordListBySubsidyApplicationId(subsidyApplicationId);
    }
}